home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- /*
- * sink.c
- *
- * sink [-1] [-D<device-file>] [size]
- *
- * Test HIPPI-FP interface input performance.
- *
- */
- #include <stdio.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #include <sys/times.h>
-
- #include <sys/hippi.h>
-
- #define DEVICE_FILE "/dev/hippi0"
-
- main(int argc, char *argv[] )
- {
- int i, n, fd, status;
- int len=0x200000, nofork = 0, retv;
- int child, arg;
- u_long *buf, *buf1,*buf2;
- char *device_name = DEVICE_FILE;
-
- arg = 1;
- if ( argc>arg && argv[arg][0] == '-' && argv[arg][1] == '1' )
- nofork++,arg++;
- if ( argc>arg && argv[arg][0] == '-' && argv[arg][1] == 'D' )
- device_name = argv[arg++]+2;
- if ( argc>arg )
- len = atoi( argv[arg++] );
-
- if ( len < 4 )
- fprintf(stderr,"Bad length argument: %d\n", len ),exit(1);
-
- buf1 = memalign( 8, len );
- buf2 = memalign( 8, len );
- printf("%s : receiving into %d size buffers\n", device_name, len );
-
- mpin( buf1, len );
- mpin( buf2, len );
-
- fd = open( device_name, O_RDONLY );
- if ( fd < 0 )
- perror( "couldn't open hippi device" ),exit(1);
-
- /* Set ULP */
- if ( ioctl( fd, HIPIOC_BIND_ULP, 0x17 ) < 0 )
- perror( "couldn't bind to ULP" ),exit(1);
-
- if ( ! nofork )
- child = ( fork() == 0 );
- else
- child = 0;
-
- buf = child ? buf1 : buf2;
-
- n=0;
- for (;;) {
- retv = read( fd, buf, len );
- if ( retv < 0 ) {
- printf("(%s) : read return value: %d\n",
- child ? "child" : "parent", retv );
- perror( "trouble reading" );
- exit(1);
- }
- n++;
- if ( ! child && (n&127) == 0 )
- printf( "%d packets received by parent\n", n );
- else if ( child && (n&127) == 64 )
- printf( "%d packets received by child\n", n );
- }
- }
-